load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//build:go_binary.bzl", "go_binary")

go_library(
    name = "go_default_library",
    srcs = ["main.go"],
    importpath = "github.com/jetstack/cert-manager/cmd/ctl",
    visibility = ["//visibility:private"],
    deps = [
        "//cmd/ctl/cmd:go_default_library",
        "//cmd/util:go_default_library",
    ],
)

go_binary(
    name = "ctl",
    out = "cmctl",
    embed = [":go_default_library"],
    pure = "on",
    visibility = ["//visibility:public"],
    x_defs = {
        "github.com/jetstack/cert-manager/cmd/ctl/pkg/build.name": "cmctl",
        "github.com/jetstack/cert-manager/cmd/ctl/pkg/build/commands.registerCompletion": "true",
    },
)

go_binary(
    name = "kubectl-cert_manager",
    out = "kubectl-cert_manager",
    embed = [":go_default_library"],
    pure = "on",
    visibility = ["//visibility:public"],
    x_defs = {
        "github.com/jetstack/cert-manager/cmd/ctl/pkg/build.name": "kubectl cert-manager",
        "github.com/jetstack/cert-manager/cmd/ctl/pkg/build/commands.registerCompletion": "false",
    },
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [
        ":package-srcs",
        "//cmd/ctl/cmd:all-srcs",
        "//cmd/ctl/pkg/approve:all-srcs",
        "//cmd/ctl/pkg/build:all-srcs",
        "//cmd/ctl/pkg/check:all-srcs",
        "//cmd/ctl/pkg/completion:all-srcs",
        "//cmd/ctl/pkg/convert:all-srcs",
        "//cmd/ctl/pkg/create:all-srcs",
        "//cmd/ctl/pkg/deny:all-srcs",
        "//cmd/ctl/pkg/experimental:all-srcs",
        "//cmd/ctl/pkg/factory:all-srcs",
        "//cmd/ctl/pkg/inspect:all-srcs",
        "//cmd/ctl/pkg/install:all-srcs",
        "//cmd/ctl/pkg/renew:all-srcs",
        "//cmd/ctl/pkg/status:all-srcs",
        "//cmd/ctl/pkg/version:all-srcs",
    ],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
